package com.zhz.lib.project.service.news;

import java.util.List;

import org.apache.log4j.Logger;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zhz.lib.project.domain.news.Sortmap;
import com.zhz.lib.project.ibatis.dao.bookreview.BookreviewDAO;
import com.zhz.lib.project.ibatis.domain.bookreview.Bookreview;
import com.zhz.lib.project.vo.bookreview.BookreviewVO;
import com.zhz.project.common.util.hibernate.BaseDAO;

/**
 * @author LiWei <a href="mailto:liwei2672@gmail.com">liwei2672@gmail.com</a>
 * @version 创建时间：2010-5-2 下午08:42:32
 * 
 */
@Service
public class BookreviewService {
    private static Logger  logger                 = Logger.getLogger(BookreviewService.class);
    @Autowired
    private BaseDAO        baseDao;
    @Autowired
    private BookreviewDAO  bookreviewDAO;

    // 最新消息类型
    private static Integer bookreviewtypefatherid = 5;

    @SuppressWarnings("unchecked")
    public List<Sortmap> getBookreviewType() {

        // 查询数据库，得到类型
        return (List<Sortmap>) baseDao.findbyorderlimit("Sortmap", "fatherId", Integer
            .toString(bookreviewtypefatherid), "order by sortMapId ASC");
    }

    public BookreviewVO getBookreviewById(int id) {

        Bookreview bookreview = bookreviewDAO.getById(id);
        BookreviewVO bookreviewVO = new BookreviewVO();
        BeanUtils.copyProperties(bookreview, bookreviewVO);
        Sortmap type = (Sortmap) baseDao.findOneObject("Sortmap", "sortMapId", bookreview
            .getSubject());
        bookreviewVO.setSubject(type.getValue());
        return bookreviewVO;
    }

    /**
     * 点击次数增加1
     * 
     * @param hotlinkVO
     * @return
     */
    public void bookreviewHitPlusOne(int id) {
        bookreviewDAO.bookreviewHitPlusOne(id + "");
    }
}
